package com.totoro.domain;

import java.util.Collection;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

/**
 * 定义角色实体类
 */
@Entity
@Table(name = "role")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Role extends BaseDomain {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer id;

	private String no;// 角色编号(主键)

	/*
	 * 1.一对多要添加mappedBy映射 2.FetchType.EAGER：急加载，加载一个实体时，定义急加载的属性会立即从数据库中加载
	 */
	@OneToMany(mappedBy = "role", fetch = FetchType.LAZY)
	private Collection<RoleResource> roleResource;// 关联的RoleResource类

	/*
	 * 1.一对多要添加mappedBy映射， 2.FetchType.EAGER：急加载，加载一个实体时，定义急加载的属性会立即从数据库中加载
	 */
	@OneToMany(mappedBy = "role", fetch = FetchType.LAZY)
	private Collection<UserRole> userRole;// 关联的UserRole类

	private String discription;// 角色的描述

	/*
	 * 1.一对多要添加mappedBy映射， 2.FetchType.EAGER：急加载，加载一个实体时，定义急加载的属性会立即从数据库中加载
	 */
	@OneToMany(mappedBy = "role", fetch = FetchType.LAZY)
	private Collection<NoticeRole> noticeRole;// 关联的NoticeRole类

	/**
	 * @generated
	 */
	@Column(name = "NAME_")
	private String name;// 名称
	/**
	 * @generated
	 */
	private Integer rank;// 级别

	// 空的构造器
	public Role() {
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getNo() {
		return no;
	}

	public void setNo(String no) {
		this.no = no;
	}

	public Collection<RoleResource> getRoleResource() {
		return roleResource;
	}

	public void setRoleResource(Collection<RoleResource> roleResource) {
		this.roleResource = roleResource;
	}

	public Collection<UserRole> getUserRole() {
		return userRole;
	}

	public void setUserRole(Collection<UserRole> userRole) {
		this.userRole = userRole;
	}

	public String getDiscription() {
		return discription;
	}

	public void setDiscription(String discription) {
		this.discription = discription;
	}

	public Collection<NoticeRole> getNoticeRole() {
		return noticeRole;
	}

	public void setNoticeRole(Collection<NoticeRole> noticeRole) {
		this.noticeRole = noticeRole;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getRank() {
		return rank;
	}

	public void setRank(Integer rank) {
		this.rank = rank;
	}

}